﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200004D RID: 77
	public class SByteArrayFormatter : IMessagePackFormatter<sbyte[]>
	{
		// Token: 0x06000123 RID: 291 RVA: 0x00004BE1 File Offset: 0x00002FE1
		private SByteArrayFormatter()
		{
		}

		// Token: 0x06000124 RID: 292 RVA: 0x00004BEC File Offset: 0x00002FEC
		public int Serialize(ref byte[] bytes, int offset, sbyte[] value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			int num = offset;
			offset += MessagePackBinary.WriteArrayHeader(ref bytes, offset, value.Length);
			for (int i = 0; i < value.Length; i++)
			{
				offset += MessagePackBinary.WriteSByte(ref bytes, offset, value[i]);
			}
			return offset - num;
		}

		// Token: 0x06000125 RID: 293 RVA: 0x00004C3C File Offset: 0x0000303C
		public sbyte[] Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			int num = offset;
			int num2 = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
			offset += readSize;
			sbyte[] array = new sbyte[num2];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = MessagePackBinary.ReadSByte(bytes, offset, out readSize);
				offset += readSize;
			}
			readSize = offset - num;
			return array;
		}

		// Token: 0x04000041 RID: 65
		public static readonly SByteArrayFormatter Instance = new SByteArrayFormatter();
	}
}
